#!/bin/bash

. $LKP_SRC/lib/upload.sh

. $LKP_SRC/lib/job.sh
load_job_vars os result_root

prepare_env()
{
	echo "prepare_env():start"
	yum install -y git
	echo "prepare_env():end"
}

update_mugen_src()
{
	echo "update_mugen_src():start"
	cd $TMP
	git clone git://172.168.178.72:9418/mugen
	mkdir gitee-src
	cd gitee-src
	for i in `seq 1 100`
	do
		git clone https://gitee.com/openeuler/mugen.git
		if [ $? -eq 0 ];then
			echo "get mugen src from gitee.com successfully."
			break
		fi
		echo "tried $i time(s) to get mugen src from gitee.com."
		sleep 600
	done
	if [ $i -lt 100 ];then
		cd ..
		cp -rf gitee-src/mugen/* mugen
		cd mugen
		git add .
		git commit -m "update" || true
		git push || true
	else
		echo "Has tried 100 times to get mugen src from gitee.com,but failed!"
		exit 100
	fi
	echo "update_mugen_src():end"
}

prepare_env
update_mugen_src
